#include "dialog.h"
#include "ui_dialog.h"

Dialog::Dialog(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::Dialog)
{
    ui->setupUi(this);
    //下面进行手动写的信号和槽进行连接
    connect(ui->radioButtonred, SIGNAL(clicked()), this, SLOT(do_fontColor()));
    connect(ui->radioButton_black, SIGNAL(clicked()), this, SLOT(do_fontColor()));
    connect(ui->radioButton_pink, SIGNAL(clicked()), this, SLOT(do_fontColor()));
}
Dialog::~Dialog()
{
    delete ui;
}

void Dialog::on_pushButton_2_clicked()
{
    ui->plainTextEdit->clear();
}


void Dialog::on_checkBox_clicked(bool checked)
{
    QFont font = ui->plainTextEdit->font();
    font.setUnderline(checked);
    ui->plainTextEdit->setFont(font);
}


void Dialog::on_checkBox_2_clicked(bool checked)
{
    QFont font = ui->plainTextEdit->font();
    font.setBold(checked);
    ui->plainTextEdit->setFont(font);
}


void Dialog::on_checkBox_3_clicked(bool checked)
{
    QFont font = ui->plainTextEdit->font();
    font.setItalic(checked);
    ui->plainTextEdit->setFont(font);
}
//设置颜色的代码实现
void Dialog::do_fontColor()
{
    QPalette plet = ui->plainTextEdit->palette();

    if(ui->radioButtonred->isChecked())
    {
        plet.setColor(QPalette::Text,Qt::red);
    }

    if(ui->radioButton_black->isChecked())
    {
        plet.setColor(QPalette::Text,Qt::black);
    }

    if(ui->radioButton_pink->isChecked())
    {
        QColor pinkColor = QColor::fromRgb(255, 192, 203);
        plet.setColor(QPalette::Text,pinkColor);
    }
    ui->plainTextEdit->setPalette(plet);
}

